import time
import os
import cv2
import numpy as np
import tensorflow as tf

from retinaface import Retinaface

gpus = tf.config.experimental.list_physical_devices(device_type='GPU')
for gpu in gpus:
    tf.config.experimental.set_memory_growth(gpu, True)

if __name__ == '__main__':
    retinaface = Retinaface()

    root_dir = '../dataset/color'
    for root, dirs, files in os.walk(root_dir):
        if files:
            for file in files:
                file_path = root + file
                image = cv2.imread(file_path)
                image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
                r_image = retinaface.detect_image(image)
                r_image = cv2.cvtColor(r_image, cv2.COLOR_RGB2BGR)
